package com.study.talk.module.netty.handler;

import com.study.talk.module.netty.message.request.HeartBeatRequest;
import com.study.talk.module.netty.message.response.HeartBeatResponse;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 心跳消息处理
 */

@Component
@Slf4j
@ChannelHandler.Sharable
public class HeartBeatRequestHandler extends SimpleChannelInboundHandler<HeartBeatRequest> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, HeartBeatRequest msg) throws Exception {
        log.info("HeartBeatRequest,心跳消息");
        ctx.channel().writeAndFlush(new HeartBeatResponse());
    }
}
